package CtrLayer;

import java.util.ArrayList;

import ModelLayer.*;

public class SalgCtr {

	private SalgContainer salgCon;
	
	/**
	 * Tlf for the new sale being created*/
	private String tlf;
	
	/**
	 * SalgNr algo
	 * */
	private int salgCount = 1;
	private int salgNr = 0;
	/**
	 * Create instance to SalgContainer and get its singleton
	 * */
	public SalgCtr()
	{
		salgCon = SalgContainer.getInstance();
	}
	/**
	 * Start new Sale.
	 * Sets the tlf field equal to nothing. And then takes para input and assigns it to tlf field
	 * @param String tlf
	 * */
	public void startNewSale(String tlf)
	{
		this.tlf = tlf;
		if(salgCount >= 2){
			salgNr++;
		}else{
			salgCount++;
		}
		createNewSale();
	}
	/**
	 * Create new sale
	 * @param String salgsDato
	 * */
	public void createNewSale()
	{
		salgCon.createSalg();
	}
	/**
	 * Take the salgNr field and use to find the sale.
	 * Then create a new DelSalg object and add it to a Salg object.
	 * @param int artikelNr, int antal, int salgNr
	 * */
	public void addDelSalgToSale(int aN, int a, int sN)
	{
		salgCon.addDelSalgToSalg(aN, a, sN);
	}
	/**
	 * Add discount to salg
	 * @param int percent
	 * */
	public void addDiscountToSalg(int p)
	{
		salgCon.addRabatToSalg(salgNr, p);
	}
	/**
	 * Get the price of the current sale
	 * @return float price
	 * */
	public float getPriceOfSalg(int sN)
	{
		return salgCon.getSalgPrice(sN);
	}
	/**
	 * Add Kunde to salg
	 * */
	public void addKundeToSalg()
	{
		salgCon.addKundeToSalg(tlf, salgNr);
	}
	/**
	 * Set the salg to betalt or not betalt
	 * @param int salgNr
	 * Get the salg status.
	 * @return boolean betalt
	 * */
	public void setBetaltStatus()
	{
		salgCon.setBetalt(salgNr);
	}
	public boolean getBetaltStatus()
	{
		return salgCon.getBetalt(salgNr);
	}
	/**
	 * Get an arrayList of all salg
	 * @return ArrayList<salg>
	 * */
	public ArrayList<Salg> getAllSalg()
	{
		return salgCon.getAllSalg();
	}
}
